package com.ybn.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ybn.entity.VoteSubject;
import org.apache.ibatis.annotations.*;


public interface VoteSubjectMapper extends BaseMapper<VoteSubject> {
    @Select("SELECT * FROM vote_subject ORDER BY VS_ID")
    @Results(id = "subject_Map", value = {
            @Result(property="vsid",column = "VS_ID"),
            @Result(property = "options", column = "VS_ID",many = @Many(select = "com.ybn.mapper.VoteOptionMapper.findOptionById")),
            @Result(property = "items", column = "VS_ID",many = @Many(select = "com.ybn.mapper.VoteItemMapper.findItemById")),
    })public IPage<VoteSubject> findAll(IPage<VoteSubject> page);

    @Select("SELECT * FROM vote_subject WHERE VS_ID = #{vsid}")
    @ResultMap("subject_Map")
    public VoteSubject getVoteSubjectById(Integer vsid);

}
